﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyWeb.ServiceBus.Model
{
    /// <summary>
    /// 返回结果
    /// </summary>
    public class ApiResult
    {
        /// <summary>
        /// 返回结果
        /// </summary>
        public ApiResult()
        {

        }
        /// <summary>
        /// 返回结果
        /// </summary>
        /// <param name="success"></param>
        /// <param name="msg"></param>
        /// <param name="res"></param>
        public ApiResult(bool success, string msg = "", object? res = null)
        {
            this.Success = success;
            this.Message = msg;
            this.Result = res;
        }
        /// <summary>
        /// 成功
        /// </summary>
        /// <param name="res">返回数据</param>
        /// <returns></returns>
        public static ApiResult SUCCESS()
        {
            return new ApiResult(true, "成功", null);
        }
        /// <summary>
        /// 成功
        /// </summary>
        /// <param name="res">返回数据</param>
        /// <returns></returns>
        public static ApiResult SUCCESS(object? res = null)
        {
            return new ApiResult(true, "成功", res);
        }
        /// <summary>
        /// 成功
        /// </summary>
        /// <param name="msg">返回信息</param>
        /// <param name="res">返回数据</param>
        /// <returns></returns>
        public static ApiResult SUCCESS(string msg = "", object? res = null)
        {
            return new ApiResult(true, string.IsNullOrWhiteSpace(msg)?"成功": msg, res);
        }
        /// <summary>
        /// 失败
        /// </summary>
        /// <param name="msg">响应消息</param>
        /// <param name="res">响应数据</param>
        /// <returns></returns>
        public static ApiResult FAILED(string msg = "", object? res = null)
        {
            return new ApiResult(false, string.IsNullOrWhiteSpace(msg) ? "失败" : msg, res);
        }

        /// <summary>
        /// 状态 是否成功
        /// </summary>
        public bool Success { get; set; } = true;

        /// <summary>
        /// 警告信息
        /// </summary>
        public string Message { get; set; } = "成功";


        /// <summary>
        /// 返回信息
        /// </summary>
        public object? Result { get; set; }
    }
}
